package com.kkd.kkdapp.receiver;

import java.util.Calendar;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

import com.kkd.kkdapp.R;
import com.kkd.kkdapp.activity.HomeActivity;
import com.kkd.kkdapp.utils.PreferenceUtils;

public class CallMeReceiver extends BroadcastReceiver {

	@Override
	public void onReceive(Context context, Intent intent) {
		// 消息通知栏
		// 定义NotificationManager
		String ns = Context.NOTIFICATION_SERVICE;
		NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns);
		// 定义通知栏展现的内容信息

		String title = intent.getStringExtra("title");
		String text = intent.getStringExtra("text");
		long when = System.currentTimeMillis();
		Notification notification = new Notification(R.drawable.kkdai_logo, title, when);

		// 定义下拉通知栏时要展现的内容信息
		Intent notificationIntent = new Intent(context, HomeActivity.class);
		PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
				notificationIntent, 0);
		notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
				| Intent.FLAG_ACTIVITY_NEW_TASK);
		notification.setLatestEventInfo(context, title, text,
				contentIntent);

		// 用mNotificationManager的notify方法通知用户生成标题栏消息通知
		mNotificationManager.notify(1, notification);
	}
}
